package com.guangzi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guangzi.entity.Media;
import com.guangzi.mapper.MediaDao;
import com.guangzi.service.AbstractService;
import com.guangzi.service.MediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MediaServiceImpl extends AbstractService implements MediaService {

    private MediaDao mediaDAO;

    @Autowired
    public void setMediaDAO(MediaDao mediaDAO) {
        super.setBaseDAO(mediaDAO);
        this.mediaDAO = mediaDAO;
    }

    @Override
    public void updateStatus(Media media) {
        mediaDAO.updateStatus(media);
    }

    @Override
    public PageInfo<Media> findAll(int pageNo, int pageSize) {

       PageHelper.startPage(pageNo,pageSize);
        List<Media> list = mediaDAO.findAll();
        PageInfo<Media> page = new PageInfo<>(list);

        return page;
    }

}
